﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Microsoft.Xna.Framework.Content;

namespace XnaXaml.Xaml
{
    public class XamlDocumentReader : ContentTypeReader<XamlDocument>
    {
        protected override XamlDocument Read(ContentReader input, XamlDocument existingInstance)
        {
            if (existingInstance == null) existingInstance = new XamlDocument();
            var xmlContent = "";
            while (input.BaseStream.Position < input.BaseStream.Length)
            {
                xmlContent += input.ReadChar().ToString();
            }
            existingInstance = new XamlDocument(xmlContent); 
            return existingInstance;
        }
    }
}
